<%@ page import="java.util.Map" %><%--
  Created by IntelliJ IDEA.
  User: xue80
  Date: 2024/12/29
  Time: 19:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%--添加Util标签包--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--引入homepage.jsp文件--%>
<%@ include file="homepage.jsp" %>
<html>
<head>
    <title>Title</title>
    <style>
        /* ListEmployee.jsp 的额外样式 */

        /* 容器样式 */
        .container {
            position: relative;
            top: 0px;
            right: -95px;
            width: 80%;
            margin: 0 auto;
            background-color: #fff;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        /* 表单样式 */
        .container1 {
            background-color: #34495e;
            padding: 20px;
            border-radius: 5px;
        }

        form {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            justify-content: center;
        }

        input[type="text"], input[type="submit"] {
            padding: 10px;
            border: none;
            border-radius: 5px;
            font-size: 16px;
        }

        input[type="submit"] {
            background-color: #e74c3c;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        input[type="submit"]:hover {
            background-color: #c0392b;
        }

        a {
            color: #3498db;
            text-decoration: none;
            transition: color 0.3s ease;
        }

        a:hover {
            color: #2980b9;
        }

        /* 表格样式 */
        .container2 table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        table, th, td {
            border: 1px solid #ddd;
        }

        th, td {
            padding: 15px;
            text-align: left;
        }

        th {
            background-color: #3498db;
            color: white;
        }

        tr:nth-child(even) {
            background-color: #f2f2f2;
        }

        /* 分页样式 */
        .page-links {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .page-links a {
            margin: 0 5px;
            padding: 5px 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            transition: border-color 0.3s ease;
        }

        .page-links a:hover {
            border-color: #3498db;
        }
    </style>
</head>
<body>
<%--添加form表单(搜索栏)--%>
<div class="container">
    <h1>客户公司管理列表</h1>
    <div class="container1">
        <form action="${pageContext.request.getContextPath()}/selectAllCustomerCompany" method="post">
            <span>开始搜索:</span>
            <input type="text" name="name" placeholder="公司名称模糊查询">
            <input type="text" name="work" placeholder="主营业务模糊查询">
            <input type="submit" value="搜索">
            <a href="${pageContext.request.getContextPath()}/addCustomerCompany.jsp">添加员工</a>
        </form>
    </div>

    <div class="container2">
        <c:choose>
            <c:when test='${map.get("totalCount")==0}'>
                <h1>没有查询到相关员工信息</h1>
            </c:when>
            <c:otherwise>
                <table>
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>name</th>
                        <th>address</th>
                        <th>phone</th>
                        <th>work</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items='${map.get("list")}' var="customercompany">
                        <tr>
                            <td>${customercompany.id}</td>
                            <td>${customercompany.name}</td>
                            <td>${customercompany.address}</td>
                            <td>${customercompany.phone}</td>
                            <td>${customercompany.work}</td>
                            <td>
                                <a href="${pageContext.request.getContextPath()}/preUpdateCustomerCompany?id=${customercompany.id}">预更新</a>
                                <a href="${pageContext.request.getContextPath()}/deleteCustomerCompany?id=${customercompany.id}">删除</a>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </c:otherwise>
        </c:choose>
        <div>
            <span>共${map.get("totalCount")}条记录，当前第${map.get("pageNum")}页，共${map.get('totalPageNum')}页</span>
            <%
                Map<String,Object> map=(Map<String,Object>)request.getAttribute("map");
                for(int i=1;i<=Long.valueOf(map.get("totalPageNum").toString());i++){
                    request.setAttribute("index",i);
            %>
            <a class="btn" href="${pageContext.request.getContextPath()}/ListCustomerCompany?pageNum=${index}">${index}</a>
            <% } %>
        </div>
    </div>
</div>
</body>
</html>
